const rspack = require('@rspack/core');
const { VueLoaderPlugin } = require('vue-loader');
const { CodeInspectorPlugin } = require('code-inspector-plugin');
const isDev = process.env.NODE_ENV == 'development';
/** @type {import('@rspack/cli').Configuration} */
const config = {
  context: __dirname,
  entry: {
    main: './src/main.js',
  },
  plugins: [
    CodeInspectorPlugin({
      bundler: 'rspack',
    }),
    new VueLoaderPlugin(),
    new rspack.HtmlRspackPlugin({
      template: './index.html',
    }),
  ],
  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: 'vue-loader',
        options: {
          experimentalInlineMatchResource: true,
        },
      },
      {
        test: /\.(js|ts)$/,
        use: [
          {
            loader: 'builtin:swc-loader',
            options: {
              sourceMap: true,
              jsc: {
                parser: {
                  syntax: 'typescript',
                  tsx: false,
                },
              },
              env: {
                targets: [
                  'chrome >= 87',
                  'edge >= 88',
                  'firefox >= 78',
                  'safari >= 14',
                ],
              },
            },
          },
        ],
      },
      {
        test: /\.svg/,
        type: 'asset/resource',
      },
    ],
  },
};
module.exports = config;
